﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using System.Data.OleDb;

namespace DAO
{
    public class ReceiverDAO
    {
        DataProvider dp = new DataProvider();

        public List<ReceiverDTO> GetAllReceiver()
        {
            List<ReceiverDTO> lst = null;
            OleDbConnection conn = dp.ConnectionData();
            try
            {
                string strSql = "select * from Receiver";

                OleDbCommand cmd = new OleDbCommand(strSql, conn);

                OleDbDataReader dr = cmd.ExecuteReader();

                ReceiverDTO receiver= null;
                lst= new List<ReceiverDTO>();
                while (dr.Read())
                {
                    receiver = new ReceiverDTO();
                    receiver.ID = (int)dr["ID"];
                    receiver.Email = (string)dr["Email"];
                    receiver.Name = (string)dr["Name"];
                    receiver.PublicKey = (string)dr["PublicKey"];

                    lst.Add(receiver);
                }

            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return lst;
        }
    }
}
